<%@page import="com.portal4kids.controller.PeopleManager"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.portal4kids.model.PeopleVisitPlan"%>
<%@page import="java.util.List"%>
<%@page import="com.portal4kids.model.People"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/themes/base/jquery.ui.all.css">
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<link rel="stylesheet" href="css/search_style.css">
<link rel="stylesheet" href="css/detail_style.css">
<title>Portal4kids - Panel Użytkownika</title>

<style>
		body { font-size: 62.5%; }
		input {width: 85px;}
		a {color: black;}
		a:HOVER {color: grey;}
		fieldset { padding:0; border:0; margin-top:25px; }
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain { width: 775px; margin-left: auto; margin-right: auto;}
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
		.ui-dialog .ui-state-error { padding: .3em; }
		.validateTips { border: 1px solid transparent; padding: 0.3em; }
</style>		
</head>
<body background="images/bg_search.jpg">
<div id="top">
	<div style="float: left; width: 100%; margin-top:43px;"> 
		<h2 style="text-align: center; font-family: Myriad Pro;">Panel użytkownika</h2>
	</div>
 
</div>
<% People user = (People)session.getAttribute("user"); 
	if(user != null){
%>
<div id="users-contain" class="ui-widget">	
	<div id="d_all">
      <div id="d_top1">
     
             <div class="d_a">
              <div class="a">Nazwa </div>
             </div>
             <div class="d_b" style="width: 150px;">
                <div class="b"><%= user.getFirstname() + " " + user.getSurname() %></div>
             </div>
             
             <div class="d_a" style="margin-left: 60px;">
                <div class="a"><a href="userPanel.jsp"> Powrót</a></div>
             </div>
             <div class="d_a" style="float: right;">
                <div class="a" ><a href="login.jsp?id=logout"> Wyloguj</a></div>
             </div>
             
        
      </div>
      <%	List<PeopleVisitPlan> visitPlan = new ArrayList<PeopleVisitPlan>();
      		PeopleManager man = new PeopleManager();
			visitPlan = man.getPlanListFromDB(user.getId_people());
			System.out.println("Plan: " + visitPlan);
			%>
      <div id="d_bottom">
        <div id="d_bottom_userPanel">
        <h2 style="color:black; text-align: center;">Edytuj Plan Wizyt:</h2> </br>
        <form action="editPlan" method="post">
        	<input type="hidden" name="plan.id_plan" value="<%=visitPlan.iterator().next().getId_plan() %>">
        	<input type="hidden" name="id_people" value="<%=user.getId_people() %>">
	        <div id="users-contain" class="ui-widget">
	        	<div style="float: left; max-width: 790px;">
				<table id="users" class="ui-widget ui-widget-content" align="center" >
						<thead>
						<tr class="ui-widget-header ">
							<th>Poniedziałek</th>
							<th>Wtorek</th>
							<th>Środa</th>
							<th>Czwartek</th>
							<th>Piątek</th>
							<th>Sobota</th>
							<th>Niedziela</th>
						</tr>
						</thead>
						<tbody>
						
							
								<tr>
									<td><input type="text" name="plan.monday" value="<%= visitPlan.iterator().next().getMonday() %>"  /></td>
									<td><input type="text" name="plan.tuesday" value="<%= visitPlan.iterator().next().getTuesday() %>"  /></td>
									<td><input type="text" name="plan.wednesday" value="<%= visitPlan.iterator().next().getWednesday() %>"  /></td>
									<td><input type="text" name="plan.thursday" value="<%= visitPlan.iterator().next().getThursday() %>"  /></td>
									<td><input type="text" name="plan.friday" value="<%= visitPlan.iterator().next().getFriday() %>"  /></td>
									<td><input type="text" name="plan.saturday" value="<%= visitPlan.iterator().next().getSaturday() %>"  /></td>
									<td><input type="text" name="plan.sunday" value="<%= visitPlan.iterator().next().getSunday() %>"  /></td>
								</tr>
								
								<tr>
									<td colspan="7">&nbsp</td>
								</tr>	
								<tr>
									<td colspan="7" style="text-align: center;"><input type="submit" value="Zapisz"> <s:a action="userPanel.jsp"></s:a> </td>
									
								</tr>
								</tbody>
									
					</table>
					</div>
			</div>
		</form>
        </div>
      </div>
  </div>
	
</div>
 <%} else{ %>
 	<h1>Nie masz uprawnień do przeglądania tej strony!</h1>
 <%} %>
</body>
</html>